﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using CF_DAL_WS.Helpers;

namespace CF_DAL_WS.Repositories
{
    public class ValidationRepository
    {
        public string ValidateUser(string username, string password)
        {
            string errtxt = "";
            try
            {
                var result = Membership.ValidateUser(username, password);
                if (!result)
                {
                    errtxt = "Login failed or invalid user!";
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    errtxt = ex.InnerException.Message;
                }
                else
                {
                    errtxt = ex.Message;
                }
            }
            GlobalVariables.Logger.Error("ValidateUser: " + errtxt);
            return errtxt;
        }
    }
}